DELETE FROM filtron_filter_engine_comments
WHERE filter_engine_id IN (
  SELECT filter_engine_id 
  FROM filtron_filter_engines
  WHERE filter_id IN (
    SELECT filtron_filters.filter_id FROM filtron_filters 
    WHERE filter_number NOT IN (
      SELECT nazwa COLLATE Polish_CI_AI from import_filtron_filtry_bac
    )
  )
);
GO

DELETE FROM filtron_filter_engines
WHERE filter_id IN (
  SELECT filtron_filters.filter_id FROM filtron_filters 
  WHERE filter_number NOT IN (
    SELECT nazwa COLLATE Polish_CI_AI from import_filtron_filtry_bac
  )
);
GO


DELETE FROM filtron_logistics_info
WHERE filter_id IN (
  SELECT filtron_filters.filter_id FROM filtron_filters 
  WHERE filter_number NOT IN (
    SELECT nazwa COLLATE Polish_CI_AI from import_filtron_filtry_bac
  )
);
GO

DELETE FROM filtron_interchanges
WHERE filter_id IN (
  SELECT filtron_filters.filter_id FROM filtron_filters 
  WHERE filter_number NOT IN (
    SELECT nazwa COLLATE Polish_CI_AI from import_filtron_filtry_bac
  )
);
GO

DELETE FROM filtron_special_filters
WHERE filter_id IN (
  SELECT filtron_filters.filter_id FROM filtron_filters 
  WHERE filter_number NOT IN (
    SELECT nazwa COLLATE Polish_CI_AI from import_filtron_filtry_bac
  )
);
GO

DELETE FROM filtron_filters 
WHERE filter_number NOT IN (
  SELECT nazwa COLLATE Polish_CI_AI from import_filtron_filtry_bac
);
GO


DELETE FROM filtron_interchanges;
DELETE FROM wix_interchanges;
